package com.team5.controller;

import com.team5.entity.News;
import com.team5.entity.RFRange;
import com.team5.response.Code;
import com.team5.response.Result;
import com.team5.service.RFRangeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RequestMapping("/rFRange")
@RestController
public class RFRangeController {
    @Autowired
    private RFRangeService service;
    @RequestMapping("/findById")
    public Result findByID(int id){
        RFRange rfRange = service.findById(id);
        return new Result(Code.SELECT_OK,rfRange);
    }
    @RequestMapping("/findAll")
    public Result findAll(){
        RFRange[] rfRanges = service.findAll();
        return new Result(Code.SELECT_OK,rfRanges);
    }
    @RequestMapping(value = "/topGainers", method = RequestMethod.GET)
    public Result findTopGainers() {
        List<RFRange> topGainers = service.findTopGainers();
        return new Result(Code.SELECT_OK, topGainers);
    }

    @RequestMapping(value = "/topLosers", method = RequestMethod.GET)
    public Result findTopLosers() {
        List<RFRange> topLosers = service.findTopLosers();
        return new Result(Code.SELECT_OK, topLosers);
    }
}
